#include <vector>
#include <set>
#include <iostream>
#include <unordered_map>
#include <numeric>

using namespace std;

string myreverseStr(string s, int k) {
    int i = 0, len = 0;
    while(i < s.size()){
        s.size()-i > k ? len = i+k-1 :len = s.size()-1;
        for(int j = i; j < len; j++){
            char temp = s[j];
            s[j] = s[len+i-j];
            s[len+i-j] = temp; 
        }
        i += 2*k;
    }
    return s;
}

string reverseStr(string s, int k) {
    int n = s.length();
    for (int i = 0; i < n; i += 2 * k) {
        reverse(s.begin() + i, s.begin() + min(i + k, n));
    }
    return s;
}

int main(){
    string s = "abcdefg";
    s = reverseStr(s, 2);
    for(char ch : s){
        cout << ch;
    }
    cout << endl;
    return 0;
}